﻿using UnityEngine;
using System.Collections;

public class AnimationTrigger : AnimateObjects 
{
    public bool onlyPlayer = true;

    void OnDetect(GameObject gObject)
    {
        if (onlyPlayer)
        {
            if ("Player".Equals(gObject.tag))
                Animate();
        }
        else
            Animate();
    }

    void OnCollisionEnter(Collision collision)
    {
        OnDetect(collision.gameObject);
    }

    void OnCollisionEnter2D(Collision2D collision)
    {
        OnDetect(collision.gameObject);
    }

    void OnTriggerEnter(Collider other)
    {
        OnDetect(other.gameObject);
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        OnDetect(other.gameObject);
    }
}
